package cn.tedu.health.controller;

import cn.tedu.health.pojo.entity.RiskPredictions;
import cn.tedu.health.response.JsonResult;
import cn.tedu.health.service.IRiskPredictionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@RestController
@RequestMapping("/api")
public class RiskPredictionsController {

    @Autowired
    private IRiskPredictionsService riskPredictionsService;

    @PostMapping("/riskpredictions")
    public JsonResult createRiskPrediction(@RequestBody RiskPredictions riskPredictions) {
        riskPredictionsService.createRiskPrediction(riskPredictions);
        return JsonResult.ok();
    }

    @GetMapping("/riskpredictions")
    public JsonResult getRiskPrediction(@RequestParam Long userId, @RequestParam LocalDate date) {
        RiskPredictions riskPrediction = riskPredictionsService.getRiskPrediction(userId, date);
        return JsonResult.ok(riskPrediction);
    }
}
